<?php
include '../config/auth.php';
function success($res){
    $result = [
        'error'=>0,
        'message'=>$res,
    ];
    return json_encode($result);
}

function error($msg){
    $data = [
        'error'=>1,
        'message'=>$msg
    ];
    return json_encode($data);
}

try {
    $config = include '../config/db.php';
    $db = new PDO($config['dsn'],$config['username'],$config['password']);
    $statement=$db->prepare('select COUNT(user_name) from user_room where room_id=:room_id ');
    $statement->execute([':room_id'=> $_GET['id']]);
    $count=$statement->fetch();
    $result=$count[0];
} catch (PDOException $e) {
    die('程序出错');
}

echo success($result);